The present invention relates to a server device which operates in response to a received request. In particular, the present invention relates to a server device in which multiple processors operate in parallel in response to multiple received requests.
As businesses utilizing web servers have become increasingly active in recent years, the web servers are required to have highly-sophisticated and complex functions. For example, there is a case where a web server receives a large number of requests in parallel simultaneously. In order to effectively respond to these requests, a large-scale web server is configured with multiple CPUs, thereby operating multiple threads in parallel on an operating system by allocating each of the multiple requests to each of the respective threads.
An effective way for effectively processing a request in a web server is to shorten waiting time (hereafter referred to as idle time) between a time when a thread completes the process for a request and a time when the thread initiates the process for the next request, or to eliminate the idle time altogether. In order to achieve such an effective process, each thread may simply retrieve a request which has been received but unprocessed upon completion of the process of the previous request. However, if each of the multiple threads independently retrieves a request in such a way, the efficiency may become low.
To be more precise, in the case where not only a web server but also any server device each communicates with a client device based on TCP/IP protocol or the like, an interface known as a socket interface is often used. For example, a socket interface developed for a BSD UNIX operating system and a Winsock interface of a Windows operating system are well-known (refer to home page URL “http://e-words.jp/w/Winsock.html (retrieved on 18 Apr. 2007)” for Winsock.)
For this socket interface, a request received from a client device is stored in system memory space by the functions of an operating system and a device driver, in association with identification information called a file descriptor. When a thread attempts to retrieve a request which has been received but unprocessed, the thread has to scan this system memory space to read out a request corresponding to each of the file descriptors and to determine whether or not the request is a received-but-unprocessed request.
Since this retrieval requires access to the system memory space, it is often necessary to invoke a system call. In addition, when each thread independently performs this retrieval, a problem may arise, for example, where one request is allocated to multiple threads. Hence, it is preferable that exclusive control be performed among threads for this retrieval (this exclusive control is also performed as a system call function in many cases). For this reason, when each thread independently performs such retrieval, processing requires a longer period of time. Hence, such retrieval may lead to even worse overall performance for a web server.
In contrast, the time required for processing system calls can be shortened in a way so that only a certain thread performs such retrieval for allocating requests to other threads. However, such processing with the certain thread is not primary processing performed by the web server in response to requests. Hence, if the retrieval processing is frequently performed excessively, the overall processing performance of the web server may be rather deteriorated. On the other hand, if the operating frequency of this certain thread is set to be excessively low, idle time may be increased. This is because, even if requests have been received, the certain thread cannot promptly allocate the received requests to other threads.